package hn.sigit.model.hnd.administrative.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.Component;

import hn.sigit.model.hnd.administrative.HND_Transaction;
import hn.sigit.model.util.SigitDAO;

public class HND_TransactionDAO extends SigitDAO<HND_Transaction> {
	private static final long serialVersionUID = 1L;
	
	private HND_TransactionDAO() {
	}

	public static List<HND_Transaction> loadTransactions() {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadTransactions(commonsDatabase);
	}	
	public static HND_Transaction loadTransactionByPresentationId(long presentationId) {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		return loadTransactionByPresentationId(commonsDatabase, presentationId);
	}
	
	@SuppressWarnings("unchecked")
	public static List<HND_Transaction> loadTransactions(Session session) {
		Criteria criteria = session.createCriteria(HND_Transaction.class);
		
		return (List<HND_Transaction>)criteria.list();
	}
	
	public static HND_Transaction loadTransactionByPresentationId(Session session, long presentationId) {
		Criteria criteria = session.createCriteria(HND_Transaction.class);
		criteria.add(Restrictions.eq("presentationId", presentationId));
		
		return (HND_Transaction)criteria.uniqueResult();
	}
	
	/*
	public static HND_Transaction createPresentation() {
		return new HND_Transaction();
	}
	
	public static void save(HND_Transaction presentation) {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		commonsDatabase.saveOrUpdate(presentation);
	}
	
	public static void delete(HND_Transaction presentation) {
		Session commonsDatabase = (Session)Component.getInstance(COMMONS_DB);
		commonsDatabase.delete(presentation);
	}
	*/
}
